package unclassified.medium;

import java.util.Deque;
import java.util.LinkedList;

public class EliminationGame_390 {

    public int lastRemaining(int n) {
        return n == 1 ? 1 : 2 * (n / 2 + 1 - lastRemaining(n / 2));
    }

    public static void main(String[] args) {
        EliminationGame_390 eg = new EliminationGame_390();
        System.out.println(eg.lastRemaining(9));
    }
}
